package com.wkbb.basic.thread;

import com.wkbb.basic.service.StudentService;
import com.wkbb.common.enums.ChangeClassOperateTypeEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * 换班操作异步处理
 * */
@Slf4j
public class ChangeClassStudentTask implements Runnable {

    private Integer operateType;
    private StudentService studentService;
    private Long orgId;
    private Long gradeId;
    private Long classId;
    private Long userId;
    private String operateUser;

    public ChangeClassStudentTask(Integer operateType,StudentService studentService, Long orgId, Long gradeId, Long classId, Long userId, String operateUser) {
        this.operateType = operateType;
        this.studentService = studentService;
        this.orgId = orgId;
        this.gradeId = gradeId;
        this.classId = classId;
        this.userId = userId;
    }

    @Override
    public void run() {
        try {
            log.info("进入换班升班操作异步处理开始.....start，orgId:{}，gradeId:{} classId:{},userId:{}",orgId,gradeId,classId,userId);

            if(operateType == ChangeClassOperateTypeEnum.CHANGE_CLASS_TO_STUDENT_PERSON.getCode().intValue()) {
                studentService.changeClassForStudent(orgId, classId, userId, operateUser);
            }
            else if(operateType == ChangeClassOperateTypeEnum.CHANGE_CLASS_TO_UP_CLASS.getCode().intValue())
            {
                studentService.changeGradeForStudent(orgId, gradeId, userId, operateUser);
            }
            log.info("进入换班升班操作异步处理结束.....");
        } catch (Exception e) {
            log.error("换班操作异步处理，{}", e);
            e.printStackTrace();
        }
    }

}
